package com.docker.chy.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.docker.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.docker.common.annotation.Log;
import com.docker.common.core.controller.BaseController;
import com.docker.common.core.domain.AjaxResult;
import com.docker.common.enums.BusinessType;
import com.docker.chy.domain.OrderTJi;
import com.docker.chy.service.IOrderTJiService;
import com.docker.common.utils.poi.ExcelUtil;
import com.docker.common.core.page.TableDataInfo;

/**
 * 订单收费统计Controller
 * 
 * @author ruoyi
 * @date 2025-04-14
 */
@RestController
@RequestMapping("/chy/dingdan")
public class OrderTJiController extends BaseController
{
    @Autowired
    private IOrderTJiService orderTJiService;

    /**
     * 查询订单收费统计列表
     */
    @PreAuthorize("@ss.hasPermi('chy:dingdan:list')")
    @GetMapping("/list")
    public TableDataInfo list(OrderTJi orderTJi)
    {
        startPage();
        List<OrderTJi> list = orderTJiService.selectOrderTJiList(orderTJi);
        return getDataTable(list);
    }

    /**
     * 导出订单收费统计列表
     */
    @PreAuthorize("@ss.hasPermi('chy:dingdan:export')")
    @Log(title = "订单收费统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OrderTJi orderTJi)
    {
        List<OrderTJi> list = orderTJiService.selectOrderTJiList(orderTJi);
        ExcelUtil<OrderTJi> util = new ExcelUtil<OrderTJi>(OrderTJi.class);
        util.exportExcel(response, list, "订单收费统计数据");
    }

    /**
     * 获取订单收费统计详细信息
     */
    @PreAuthorize("@ss.hasPermi('chy:dingdan:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(orderTJiService.selectOrderTJiById(id));
    }

    /**
     * 新增订单收费统计
     */
    @PreAuthorize("@ss.hasPermi('chy:dingdan:add')")
    @Log(title = "订单收费统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OrderTJi orderTJi)
    {
        return toAjax(orderTJiService.insertOrderTJi(orderTJi));
    }

    /**
     * 修改订单收费统计
     */
    @PreAuthorize("@ss.hasPermi('chy:dingdan:edit')")
    @Log(title = "订单收费统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OrderTJi orderTJi)
    {
        return toAjax(orderTJiService.updateOrderTJi(orderTJi));
    }

    /**
     * 删除订单收费统计
     */
    @PreAuthorize("@ss.hasPermi('chy:dingdan:remove')")
    @Log(title = "订单收费统计", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(orderTJiService.deleteOrderTJiByIds(ids));
    }
    //查询总金额
    @Anonymous
    @GetMapping("/totalAmount")
    public AjaxResult totalAmount()
    {
        return success(orderTJiService.selectTotalAmount());
    }
}
